package example.guice.web

import com.google.inject.servlet.ServletModule
import com.sun.jersey.guice.spi.container.servlet.GuiceContainer
import scala.collection.JavaConverters._
import example.guice.web.servlets.BaseHttpServlet
import com.google.inject.Scopes

class ExampleServletModule extends ServletModule {

  @Override
  override protected def configureServlets() {
    bind(classOf[BaseHttpServlet]).in(Scopes.SINGLETON)

    //serve("/", "/login.html").with(LoginServlet.class);
    serve("/", "/base.html").`with`(classOf[BaseHttpServlet]);

    //bind(classOf[GuiceContainer]);
    val initParams = Map("com.sun.jersey.config.feature.Trace" -> "true",
        "com.sun.jersey.config.property.packages" -> "example.guice.web.rest;example.guice.web.provider");
    serve("/rest/*").`with`(classOf[GuiceContainer], initParams.asJava);
  }

}